
//---------------------------------------------------------------------------
#ifndef PG2_RENDERER_H
#define PG2_RENDERER_H
//---------------------------------------------------------------------------
#include "Defines.h"
//---------------------------------------------------------------------------
#include "rendertypes.h"

#include "boundingBox.h"
//---------------------------------------------------------------------------
struct IDirect3D9;
struct IDirect3DDevice9;
struct D3DXMATRIX;
struct D3DXPLANE;
//---------------------------------------------------------------------------
	struct IDirect3DTexture9;
namespace ns
{
//---------------------------------------------------------------------------
class VertexBuffer;
class IndexBuffer;
//---------------------------------------------------------------------------
class ENGINE_API Renderer
{
// initialization
public:
	Renderer ();
	~Renderer ();

	bool init (HWND hWnd);
	IDirect3DDevice9* getDevice();


// rendering
public:
	void beginFrame ();
	void endFrame ();
	void UpdateView(float x,float y,float z,float lx,float ly,float lz);
	void UpdateWorld(D3DXMATRIX* m);
	HWND GetWnd();

private:
	IDirect3D9* m_pkD3D;
	IDirect3DDevice9* m_pkDevice;
	D3DXMATRIX* viewMatrix;
	D3DXMATRIX* matProj;
	D3DXPLANE* frustum;
	HWND _hWnd;
// vertex buffers
public:
	void draw (const ColorVertex* pakVertexCollection, Primitive ePrim, unsigned int uiVertexCount);
	void drawCurrentBuffers (Primitive ePrimitive);
	void setCurrentVertexBuffer(VertexBuffer* CurrentVB);
	void SetCurrentIndexBuffer(IndexBuffer* CurrentIB);
	void BuildViewFrustum();
	bool BoxInFrustum(BoundingBox* box);
	void SetTexture(IDirect3DTexture9* texture);

private:
	VertexBuffer* CurrentVertexBuffer;
	IndexBuffer* CurrentIndexBuffer;

};
//---------------------------------------------------------------------------
} // end namespace
//---------------------------------------------------------------------------
#endif // PG2_RENDERER_H
//---------------------------------------------------------------------------
